<?php


namespace app\model\cart;


use app\model\config\RegionModel;
use think\Model;
use think\model\concern\SoftDelete;

class VerifyCartCityModel extends Model
{
    protected $name = 'verify_cart_city';
    protected $autoWriteTimestamp = true;

    use  SoftDelete;
    protected $defaultSoftDelete = 0;

    public static function onBeforeWrite(Model $model)
    {
        $name = RegionModel::where('id', $model->city_id)->value('name');
        $model->appendData(['city_name' => $name]);
    }
}